package com.xnfh.equipment.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.xnfh.common.bean.GatDeviceSensorListBean
import com.xnfh.equipment.R
import com.xnfh.equipment.databinding.ItemSensorInfoLayoutBinding

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/12/25 14:46
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/25 14:46
 * @UpdateRemark: 更新说明
 */
class SensorInfoAdapter: BaseQuickAdapter<GatDeviceSensorListBean,BaseDataBindingHolder<ItemSensorInfoLayoutBinding>>(R.layout.item_sensor_info_layout) {
    override fun convert(holder: BaseDataBindingHolder<ItemSensorInfoLayoutBinding>, item: GatDeviceSensorListBean) {
        val dataBinding = holder.dataBinding
        when(item.Devicetype){
            3 ->{
                //水流传感器
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "（m³/h）"
            }
            4 ->{
                //肥流传感器
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "（L/h）"
            }
            20 ->{
                //管道压力
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "Bar"
            }
            23 ->{
                //液位
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "mm"
            }
            21 ->{
                //EC
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "ms/cm"
            }
            12 ->{
                //土壤水势
                dataBinding?.itemSensorInfoName?.text = item.Devicename + "cb"
            }
            else ->{
                //type = 22  PH 无单位
                dataBinding?.itemSensorInfoName?.text = item.Devicename
            }
        }
        dataBinding?.itemSensorInfoNum?.text = item.Sensorrealtimedata.toString()


    }
}